#ifndef _DRV_GD5F4GQX_H_
#define _DRV_GD5F4GQX_H_

#include <stdint.h>
#include "ISpi.h"
#include "GPIO.h"

class Drv_Gd5f4GQx
{
private:
	ISpi      				*m_pHndSpi;
	GPIOHandler				*m_pHndGpioChipSel;

	uint16_t				m_ui16PageSize;
	uint32_t				m_ui32BlockSize;

public:
	Drv_Gd5f4GQx(ISpi *pHndSpi);
	~Drv_Gd5f4GQx(void);

public:
	uint32_t GetPageSize(void);
	uint32_t GetBlockSize(void);

public:
	bool Init(void);
	bool Erase(uint16_t block);

	uint32_t Read(uint16_t block,uint16_t page,uint16_t col,uint8_t *pui8Buff,uint16_t len);
	uint32_t Read(uint16_t block,uint16_t page,uint8_t *pui8Buff,uint16_t len,uint8_t *oob,uint16_t oobLen);

	uint32_t Write(uint16_t block,uint16_t page,uint16_t col,uint8_t *pui8Buff,uint16_t len);
	uint32_t Write(uint16_t block,uint16_t page,uint8_t *pui8Buff,uint16_t len,uint8_t *oob,uint16_t oobLen);

	bool IsBlockECC(uint16_t block);

	bool IsBadBlock(uint16_t block);
	void MarkBadBlock(uint16_t block);
};

#endif
